package com.example.demo

class MyNumber {
    int value

    MyNumber(int value) {
        this.value = value
    }

    def 乘(MyNumber other) {
        new MyNumber(this.value * other.value)
    }

    def 乘(int other) {
        new MyNumber(this.value * other)
    }

    // 定义操作符重载
    def static 乘(MyNumber self, MyNumber other) {
        self.乘(other)
    }

    def static 乘(MyNumber self, int other) {
        self.乘(other)
    }
}

def num1 = new MyNumber(5)
def num2 = new MyNumber(10)

// 使用自定义操作符
def result = num1.乘 num2
println result.value
assert result.value == 50